@extends('admin/layout')
@push('style')
    <link rel="stylesheet" href="/admin/assets/css/login.css">
@endpush
@section('body')
    <div class="login-wrapper layui-anim layui-anim-scale layui-hide">
        <form class="layui-form">
            <input type="hidden" name="code" value="{{$code}}"/>
            <h2>重置密码</h2>
            <div class="layui-form-item layui-input-icon-group">
                <i class="layui-icon layui-icon-password"></i>
                <input class="layui-input" name="password" placeholder="密码"
                       type="password"
                       lay-verType="tips" lay-verify="required" required/>
            </div>
            <div class="layui-form-item layui-input-icon-group">
                <i class="layui-icon layui-icon-password"></i>
                <input class="layui-input" name="password_confirmation" placeholder="确认密码"
                       type="password"
                       lay-verType="tips" lay-verify="required" required/>
            </div>

            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid" lay-filter="loginSubmit"
                        lay-submit>重置密码</button>
            </div>
        </form>
    </div>
{{--    <div class="login-copyright">copyright © 2022 {{config('app.name', '')}} all rights reserved.</div>--}}
@stop
@push('script')
    <script>
        if (window !== top) top.location.replace(location.href);
        layui.use(['layer', 'form', 'admin', 'dropdown'], function () {
            var $ = layui.jquery, layer = layui.layer, form = layui.form, captchaUrl = '{{captcha_src()}}';
            $('.login-wrapper').removeClass('layui-hide');
            sessionStorage.clear();
            /* 表单提交 */
            form.on('submit(loginSubmit)', function (obj) {
                SystemUtil.ajax("{{admin_url('public/retrievePassword')}}")
                    .setData(obj.field)
                    .send(1)
                    .done((res) => {
                        layer.msg(res.msg, {icon: 1, time: 1500}, function () {
                            location.replace("{{admin_url('index')}}");
                        });
                    }).fail(() => {
                    $('img.login-captcha').attr('src', captchaUrl + '?t=' + (new Date).getTime());
                })
                return false;
            });
            /* 图形验证码 */
            $('img.login-captcha').click(function () {
                this.src = captchaUrl + '?t=' + (new Date).getTime();
            }).trigger('click');
            window.changeLang = function (lang) {
                setLang(lang);
                layui.admin.closeAllTabs();
                location.reload();
            }
        });
    </script>
@endpush

